package com.ysd.lis.service.lab.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.common.dto.DeletesDto;
import com.ysd.lis.entity.lab.LabItemDictSpecialRules;
import com.ysd.lis.mapper.lab.LabItemDictSpecialRulesMapper;
import com.ysd.lis.service.lab.LabItemDictSpecialRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 52771
* @description 针对表【LAB_ITEM_DICT_SPECIAL_RULES(报告项目参考范围)】的数据库操作Service实现
* @createDate 2024-07-04 09:07:16
*/
@Service
public class LabItemDictSpecialRulesServiceImpl extends ServiceImpl<LabItemDictSpecialRulesMapper, LabItemDictSpecialRules>
    implements LabItemDictSpecialRulesService{

    @Autowired
    LabItemDictSpecialRulesMapper labItemDictSpecialRulesMapper;


    @Override
    public Result findItemDictSpecialRules(LabItemDictSpecialRules labItemDictSpecialRules) {
        LambdaQueryWrapper<LabItemDictSpecialRules> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(LabItemDictSpecialRules::getItemNo,labItemDictSpecialRules.getItemNo())
                .eq(LabItemDictSpecialRules::getRptGroup,labItemDictSpecialRules.getRptGroup())
                .eq(LabItemDictSpecialRules::getDelFlag,0);
        List<LabItemDictSpecialRules> labItemDictSpecialRules1 = labItemDictSpecialRulesMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1,"查询成功",labItemDictSpecialRules1);
    }

    @Override
    public Result addItemDictSpecialRules(LabItemDictSpecialRules labItemDictSpecialRules) {
        int insert = labItemDictSpecialRulesMapper.insert(labItemDictSpecialRules);
        if(insert>0){
            return Result.succ(1, "添加成功！", null);
        } else {
            return Result.fail("添加失败！");
        }
    }

    @Override
    public Result editItemDictSpecialRules(LabItemDictSpecialRules labItemDictSpecialRules) {
        int i = labItemDictSpecialRulesMapper.updateById(labItemDictSpecialRules);
        if(i>0){
            return Result.succ(1, "修改成功！", null);
        } else {
            return Result.fail("修改失败！");
        }

    }

    @Override
    public Result deleteItemDictSpecialRules(DeletesDto deletesDto) {
        int i = labItemDictSpecialRulesMapper.deleteBatchIds(deletesDto.getIds());
        if(i>0){
            return Result.succ(1, "删除成功！", null);
        } else {
            return Result.fail("删除失败！");
        }
    }
}




